package com.unionpay.fsas;

import com.unionpay.fsas.sdk.SDKConstants;
import com.unionpay.fsas.sdk.SDKUtil;
import com.unionpay.fsas.sdk.SecureUtil;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author caoqc
 * @Description:
 * @date 2021/12/07 10:05:01
 */
public class Test {
    public static void main(String[] args) throws UnsupportedEncodingException {



     /*   stringData = stringData.replace("\n","");
        stringData = stringData.replace("\r","");*/
        String stringData = SDKUtil.coverMap2StringNew(tranMap());
        System.out.println("待验签排序串：[" + stringData + "]");
        byte[] sm3 = SecureUtil.sm3(stringData.getBytes("UTF-8"));
        String sm3Hex = SecureUtil.byte2Hex(sm3);
        System.out.println("sm3结果:[" + sm3Hex + "]");

        /*byte[] sm3Second = SecureUtil.sm3(sm3Hex.getBytes("UTF-8"));
        String sm3HexSecond = SecureUtil.byte2Hex(sm3Second).toLowerCase();
        System.out.println("第二次sm3结果:[" + sm3HexSecond + "]");
        System.out.println(sm3HexSecond);*/

    }


    private static Map tranMap(){
        Map map = new HashMap();
        map.put("txnNo","20211207113610790");
        map.put("signPubKeyCert","-----BEGIN CERTIFICATE-----\r\nMIIC0DCCAnSgAwIBAgIFEEBzAUEwDAYIKoEcz1UBg3UFADBcMQswCQYDVQQGEwJD\r\nTjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y\r\naXR5MRswGQYDVQQDDBJDRkNBIFRFU1QgU00yIE9DQTEwHhcNMjAxMTAzMDk1NTU4\r\nWhcNMjUxMTAzMDk1NTU4WjB1MQswCQYDVQQGEwJDTjEQMA4GA1UECgwHT0NBMVNN\r\nMjENMAsGA1UECwwEdGVzdDEZMBcGA1UECwwQT3JnYW5pemF0aW9uYWwtMjEqMCgG\r\nA1UEAwwhMDUxQGNoaW5hdW5pb25wYXlAWjkwNTI5MDAwMDAwOEAyMFkwEwYHKoZI\r\nzj0CAQYIKoEcz1UBgi0DQgAEkw27RvY8mAx6h7vnSW/+X3b++a1E6LzQTPWMOiKP\r\nAfZTqJMKeRnQNEKt+N7EA98YHVheOCT9TlZ3fkgtNZcH86OCAQYwggECMB8GA1Ud\r\nIwQYMBaAFGv+GNqPQjqmuG2zLoiDOjSiwTDhMAwGA1UdEwEB/wQCMAAwSAYDVR0g\r\nBEEwPzA9BghggRyG7yoBATAxMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmNmY2Eu\r\nY29tLmNuL3VzL3VzLTE0Lmh0bTA5BgNVHR8EMjAwMC6gLKAqhihodHRwOi8vdWNy\r\nbC5jZmNhLmNvbS5jbi9TTTIvY3JsMTM3MzYuY3JsMA4GA1UdDwEB/wQEAwIGwDAd\r\nBgNVHQ4EFgQUn9wz++O90r2Bc7qlzqeIhIVivD4wHQYDVR0lBBYwFAYIKwYBBQUH\r\nAwIGCCsGAQUFBwMEMAwGCCqBHM9VAYN1BQADSAAwRQIgNXTJts3vqvCbbhUKwnkI\r\nrv+HeDeyTwU4JJpBTWCR6TACIQCtQShpYt9jgxw6VSHpKEXnnWH9u4vYhXDoH42w\r\nWVaX6A==\r\n-----END CERTIFICATE-----");
        map.put("respMsg","验证签名失败[11100042007]");
        map.put("txnType","01");
        map.put("encoding","UTF-8");
        map.put("acqInsCode","49983080");
        map.put("version","1.0.0");
        map.put("respCode","11");
        map.put("signMethod","02");
        map.put("txnDate","20211207");
        return map;
    }






}
